package id.net.iconpln.bb.server.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import id.net.iconpln.bb.server.model.persistence.ModelMasterBb;
import id.net.iconpln.bb.server.model.persistence.User;
import id.net.iconpln.bb.server.model.persistence.UserBb;
import id.net.iconpln.bb.server.dao.UserDao;
import id.net.iconpln.bb.server.service.SecureService;


 @Service("secureService")
 @Transactional(readOnly=true)
	public class SecureServiceImpl implements SecureService{
	    private UserDao userDao;

	    @Autowired
	    public void setUserDao(@Qualifier("userDao")UserDao userDao) {
	         this.userDao = userDao;
	    }
	    @Override
	    @Transactional(readOnly=false)
	    public void save(User user) {
	        userDao.save(user);  
	    }
	    @Override
	    public List<User> getUser(String name, String pass) {
	    	System.out.println("Name : " + name +" Pass : "+ pass);
	         return userDao.findById(name, pass);
	    }
	    @Override
	    public List getUsers() {
	        return userDao.findAll();  
	    }
	    @Override
	    @Transactional(readOnly=false)
	    public void delete(User user) {
	        userDao.delete(user);  
	    }

	    @Override
	    public List<User> getUserByUser(String user) {
	        return userDao.getUserByUser(user);
	    }
		@Override
		public List<UserBb> getUserByLogin(String user, String Pass) {
			// TODO Auto-generated method stub
			return userDao.getUserByLogin(user, Pass);
		}


	}
